<template>
  <div>
    <el-dialog :visible.sync="dialogVisible" v-if="dialogVisible" :show-close="false" width="800px" @close="close">
      <div class="header">
        <div><span class="line"></span>{{ detail.taskInfo && detail.taskInfo.title || '' }}</div>
        <i class="el-icon-close" @click="close"> </i>
      </div>
      <div class="material-tag">
        <span class="tag" v-for="(item, index) in detail.labels">{{ item }}</span>
      </div>
      <div class="material-time">
        上传时间：{{parseTime(new Date(detail.finishTime), '{y}-{m}-{d}')}}
      </div>
      <el-row :gutter="10" class="mb8">
        <div class="material-video text-container" v-if="detail.type === 'NEWS'">
          <div v-html="detail.taskInfo.content">
          </div>
        </div>
        <!-- 图片 -->
        <div class="material-video" v-if="detail.type === 'IMAGE'">
          <img style="width: 100%;" :src="detail.taskInfo.finishedUrl" alt="">
        </div>
        <!-- 视频 -->
        <div class="material-video" v-if="detail.type === 'VIDEO'">
          <vue-d-player ref="dplayer" :options="{video: {url: detail.taskInfo.videoPath, pic: detail.coverUrl}}" :key="detail.id"></vue-d-player>
        </div>
        <!-- 文本 -->
        <div class="material-desc" v-if="detail.type === 'text'">
          {{ detail.textContent }}
        </div>
        <!-- 数字人 -->
        <div class="material-desc" v-if="detail.type === 'DIGITAL_PERSON'">
          <!-- <el-input v-model="detail.taskDigitalPerson.dialogue" type="textarea" :rows="20"></el-input> -->
          <vue-d-player ref="dplayer" :options="{video: {url: detail.taskInfo.videoPath, pic: detail.coverUrl}}" :key="detail.id"></vue-d-player>
        </div>
      </el-row>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "Preview",
  data() {
    return {
      title: "",
      dialogVisible: false,
      // 表单参数
      detail: {
        preViewUrl:'',
      },
      dp:null,
      options: {},
    };
  },
  mounted() {},
  methods: {
    close() {
      this.dialogVisible = false;
    },
    result(){
      const player = this.$refs.dplayer.dp
      console.log(player)
      
      // player.re
    },
    show(item) {
      if(item.type=='NEWS'){
        item.taskInfo = item.taskNews
      }
      if(item.type=='VIDEO'){
        item.taskInfo = item.taskVideo
      }
      if(item.type=='DIGITAL_PERSON'){
        item.taskInfo = item.taskDigitalPerson
      }
      if(item.type=='IMAGE'){
        item.taskInfo = item.taskImage
      }
      console.log(item)
      this.detail = item;
      this.dialogVisible = true;
    },
    handleEdit(){

    },
  },
};
</script>
<style scoped lang="scss">
.btn {
  width: 100%;
  padding: 20px 0;
  display: flex;
  justify-content: center;
  align-items: center;
}
.material-video{
  img{
    width: 100%;
  }
}

.material-desc{
  max-height: 500px;
  overflow-y: scroll;
  line-height: 22px;
  font-size: 14px;
}
.header{
  display: flex;
  justify-content: space-between;
  padding: 20px 0 0;
  font-size: 18px;
  font-weight: 700;
  .line{
    display: inline-block;
    width: 2px;
    height: 13px;
    background-color: #2552E4;
    margin-right: 5px;
  }
  i{
    font-size: 26px;
    cursor: pointer;
    margin-left: 60px;
  }
}
.material-time{
  margin-bottom: 10px;
  border-bottom: 1px solid #D4DEEA;
  padding-bottom: 10px;
  font-size: 12px;
}
.material-tag{
      margin: 10px 0 10px;
      .tag{
        display: inline-block;
        background: rgba(9, 184, 68, 0.08);
        color: #09B844;
        padding: 3px 10px;
        font-size: 12px;
        border-radius: 2px;
        margin-right: 10px;
      }
      .tag:last-child{
        background: rgba(0, 87, 255, 0.08);
        color: #0057FF;
      }
    }
::v-deep{
  .el-dialog__header{
    padding: 0;
  }
  .material-video{
    p{
      line-height: 26px;
      margin: 0;
    }
    img{
      width: 100%;
      margin-top: 10px;
    }
  }
}
.text-container {
      max-height: 70vh;
      overflow-y: auto;
      overflow-x: hidden;
      margin-right: -10px;
    }
</style>
